package com.sfh.cpc.home.model;

import com.sfh.cpc.com.entity.EMass;
import com.sfh.cpc.com.entity.ENote;
import com.sfh.cpc.com.entity.RspBase;
import com.sfh.cpc.home.model.request.ReqQueryHomeMass;
import com.sfh.cpc.home.model.request.ReqQueryHomeRecomNote;
import com.sfh.lib.mvvm.service.BaseViewModel;
import com.sfh.lib.rx.IResultSuccessNoFail;

import java.util.List;

/**
 * 功能描述: TODO
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/16
 */
public class HomeViewModel extends BaseViewModel  {

    /***
     * [APP 首页使用]推荐话题 4,
     */
    public void queryHomeRecomNote(int index){

        this.execute(new ReqQueryHomeRecomNote(index,ReqQueryHomeRecomNote.TYPE_A),noteResultSuccess);
    }

    /***
     * [APP 首页使用]热门 话题 6
     */
    public void queryHomeHotNote(int index){
        this.execute(new ReqQueryHomeRecomNote(index,ReqQueryHomeRecomNote.TYPE_B),noteResultSuccess);
    }

    /***
     * [APP 首页使用]最新话题 6
     */
    public void queryHomeNewNote(int index){
        this.execute(new ReqQueryHomeRecomNote(index,ReqQueryHomeRecomNote.TYPE_C),noteResultSuccess);
    }
    /***
     *[APP 首页使用]VIP 话题 9
     */
    public void queryHomeVIPNote(int index){
        this.execute(new ReqQueryHomeRecomNote(index,ReqQueryHomeRecomNote.TYPE_D),noteResultSuccess);
    }

    private IResultSuccessNoFail noteResultSuccess =  new IResultSuccessNoFail<RspBase<List<ENote>>>() {
        @Override
        public void onSuccess(RspBase<List<ENote>> listRspBase) throws Exception {
            if (listRspBase.success()){
                setValue("onNoteListSuccess",listRspBase.getData());
            }
        }
    };

    /***
     * 推荐社团 7
     */
    public void queryHomeRecomMass(int index){
        this.execute(new ReqQueryHomeMass(index,ReqQueryHomeMass.TYPE_A),massResultSuccess);
    }


    /***
     * 最新社团 4
     */
    public void queryHomeNewMass(int index){
        this.execute(new ReqQueryHomeMass(index,ReqQueryHomeMass.TYPE_B),massResultSuccess);
    }

    /***
     *VIP 社团 9
     */
    public void queryHomeVIPMass(int index){
        this.execute(new ReqQueryHomeMass(index,ReqQueryHomeMass.TYPE_C),massResultSuccess);
    }

    private IResultSuccessNoFail massResultSuccess =  new IResultSuccessNoFail<RspBase<List<EMass>>>() {
        @Override
        public void onSuccess(RspBase<List<EMass>> listRspBase) throws Exception {
            if (listRspBase.success()){
                setValue("onMassListSuccess",listRspBase.getData());
            }
        }
    };
}
